package lelouet.sh3d.plugins.sweetDatacenter;

import lelouet.sh3d.plugins.sweetDatacenter.model.GElementFactory;
import lelouet.sh3d.plugins.sweetDatacenter.model.GRack;

import com.eteks.sweethome3d.model.Selectable;
import com.eteks.sweethome3d.plugin.Plugin;
import com.eteks.sweethome3d.plugin.PluginAction;

/** and the copy-rack and paste-rack buttons */
public class CopyRackButton extends PluginAction {

	Plugin parent;
	GElementFactory bridge;

	@Override
	public void execute() {
		for (Selectable sel : parent.getHome().getSelectedItems()) {
			if (sel instanceof GRack) {
				GRack grack = (GRack) sel;
				bridge.copyGRack(grack);
			}
		}
	}

	public CopyRackButton(Plugin parent, GElementFactory bridge) {
		super("lelouet.sh3d.plugins.sweetDatacenter.ApplicationPlugin",
				"COPY_RACK", parent.getPluginClassLoader(), true);
		this.parent = parent;
		this.bridge = bridge;
	}

}
